s = input('Напишите скобочную последовательность')
stack = []
f = 1

if s[0] in ')]}>':
    f = 0

for i in s:
    if i in '([{<':
        stack.append(i)
        last = stack[-1]
        if ((i == '}' and last == '{')
        or (i == ')' and last == '(')
        or (i == '>' and last == '<')
            or (i == ']' and last == '[')
        ):
            stack.pop()
        else:
            break

if len(stack) == 0 and f == 1:
    print(True)
else:
    print(False)
